package com.muse.designpatterns.strategy.duck;

import com.muse.designpatterns.strategy.fly.FlyBehavior;
import com.muse.designpatterns.strategy.quack.QuackBehavior;

public abstract class Duck {
    //飞行行为
    protected FlyBehavior flyBehavior;
    //叫的行为
    protected QuackBehavior quackBehavior;

    public abstract void display();

    //游泳
    public void swim(){
        System.out.println("鸭子游泳");
    };

    public void fly(){
        flyBehavior.fly();
    }
    public void quack(){
        quackBehavior.quack();
    }
    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }
    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }
}
